<?php
/**
 * 配置模型
 */
class Config_model extends MY_Model{

	private $table = 'config';
	function __construct()
	{
		parent::__construct();

	}

	/**
	 * 获取配置信息列表
	 * @DateTime 2017-08-25
	 * @author xyl
	 * @param    array      $where [description]
	 * @return   [type]            [description]
	 */
	public function getConfigDetail($where=array('id'=>1))
	{

		$list = $this->hw_getRecord($this->table,$where);

		return $list;
	}	
	/**
	 * 修改或添加配置信息
	 * @DateTime 2017-08-25
	 * @author xyl
	 * @param  [type] $data  [description]
	 * @param  array  $where [description]
	 * @return [type]        [description]
	 */
	public function updateConfig($data,$where=array('id'=>1))
	{
		$config_info = $this->getConfigDetail();
		if(!empty($config_info)){
			$data['update_time'] = date('Y-m-d H:i:s');
			$res = $this->hw_Update($this->table,$data,$where);
			$type = 2;
		}else{
			$res = $this->hw_Insert($this->table,$data);
			$type = 1;
		}
		if($res){
			$return = array('code'=>1,'msg'=>'编辑成功');
		}else{
			$return = array('code'=>0,'msg'=>'编辑失败');
		}
		//添加操作日志
		$this->logMdl->addOperationLog($return['code'],$type,$res,$this->table,'配置信息',json_encode($data));
		return $return;
	}
	
}